<title>收件联系单登记-增加</title>
<!-- /section:settings.box -->
<div class="row">
	<div class="col-xs-12 aptitude_receiptAdd">
		<form class="form-horizontal registerform">
			<div class="space-4"></div>
			<div class="space-4"></div>
			<div class="space-4"></div>
			<div class="form-group">
				<label class="col-sm-3 control-label no-padding-right"
					for="form-field-name">收件时间：</label>
				<div data-link-field="dtp_input1" data-date-format="yyyy-mm-dd"
					class="input-group date form_datetime col-sm-2 fl">
					<input type="text" id="hx_sj_time" size="16"
						class="form-control col-sm-12" placeholder="请选择申请日期"> <span
						class="input-group-addon"> <span
						class="glyphicon glyphicon-remove"> </span>
					</span> <span class="input-group-addon"> <span
						class="glyphicon glyphicon-th"> </span>
					</span>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label no-padding-right"
					for="form-field-name">送件单位：</label>
				<div class="input-group col-sm-9">
					<div class="in_txt">
						<input type="text" class="input-xlarge" datatype="*"
							id="hx_sd_unit" nullmsg="请输入送件单位" placeholder="请输入送件单位" id="">
					</div>
					<div class="tishi">
						<div class="Validform_checktip"></div>
					</div>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label no-padding-right"
					for="form-field-name">经办人：</label>
				<div class="input-group col-sm-9">
					<div class="in_txt">
						<input type="text" class="input-xlarge" datatype="*"
							nullmsg="请输入联系人" placeholder="请输入联系人" id="hx_linkman">
					</div>
					<div class="tishi">
						<div class="Validform_checktip"></div>
					</div>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label no-padding-right"
					for="form-field-name">联系人及电话：</label>
				<div class="input-group col-sm-9">
					<div class="in_txt">
						<input type="text" class="input-xlarge" datatype="*"
							nullmsg="请输入联系电话" placeholder="请输入联系电话" id="hx_phone">
					</div>
					<div class="tishi">
						<div class="Validform_checktip"></div>
					</div>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label no-padding-right"
					for="form-field-name">申办内容：</label>
				<div class="input-group col-sm-9">
					<div class="in_txt">
						<select datatype="*" nullmsg="选择申办内容类型" id="hx_content">
							<option value="三级新办">三级新办</option>
							<option value="三级延续">三级延续</option>
							<option value="二级延续">二级延续</option>
							<option value="三级升二级">三级升二级</option>
							<option value="二级升一级">二级升一级</option>
						</select>
					</div>
					<div class="tishi">
						<div class="Validform_checktip"></div>
					</div>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label no-padding-right"
					for="form-field-name">资料清单：</label>
				<div class="input-group col-sm-9">
					<div class="in_txt in_txt_hover js_hover">
						<?php
						foreach ( $data as $item ) {
							?>
						<a href="javascript:;" class="btn btn-mini btn-grey"
							data-hover="guan" data-indentity="<?=$item['sys_value'] ?>"><?=$item['sys_value'] ?></a>
						 <?php
						}
						?>
					</div>
				</div>
			</div>
			<div class="space-4"></div>
			<div class="clearfix form-actions">
				<div class="col-md-offset-3 col-md-9">
					<button class="btn btn-info save" type="button" id="btnSubmit">
						<i class="ace-icon fa fa-check bigger-110"> </i> 完成登记
					</button>
					&nbsp; &nbsp;
					<button class="btn" type="button">
						<i class="ace-icon glyphicon glyphicon-remove bigger-110"> </i>
						取消登记
					</button>
				</div>
			</div>
		</form>
	</div>
	<!-- PAGE CONTENT ENDS -->
	<!-- /.col -->
</div>
<script type="text/javascript">var scripts = [null, "/datetimepicker/js/bootstrap-datetimepicker.min.js",
	"/datetimepicker/js/locales/bootstrap-datetimepicker.zh-CN.js", null
];
$('.page-content-area').ace_ajax('loadScripts', scripts, function() {
	$('.form_datetime').datetimepicker({
		minView: "month", //选择日期后，不会再跳转去选择时分秒
		format: "yyyy-mm-dd", //选择日期后，文本框显示的日期格式
		language: 'zh-CN', //汉化
		autoclose: true //选择日期后自动关闭
	});
	var $scope = $(".aptitude_receiptAdd");
	//表单验证
	var vform = $(".registerform").Validform({
		tiptype: 2
	});
	//多选项
	$(".js_hover a").click(function() {
		var this_a = $(this)
		data_hover = this_a.attr("data-hover")
		if (data_hover == "kai") {
			this_a.removeClass("btn-success")
			this_a.addClass("btn-grey")
			this_a.attr("data-hover", "guan")
		}
		if (data_hover == "guan") {
			this_a.addClass("btn-success")
			this_a.removeClass("btn-grey")
			this_a.attr("data-hover", "kai")
		}
	})
	$('#btnSubmit').click(function() {
		if (!vform.check(false)) {
			return;
		}
		var linkman = $("#hx_linkman", $scope).val();
		var phone = $("#hx_phone", $scope).val();
		var sj_time = $("#hx_sj_time", $scope).val();
		var content = $("#hx_content", $scope).val();
		var sd_unit = $("#hx_sd_unit", $scope).val();
		var material = "";
		var list = $(".js_hover a[data-hover='kai']")
		if (list.length == 0) {
			alert("请选择资料");
			return;
		}
		list.each(function() {
			material = material + $(this).attr("data-indentity") + ",";
		});
		material = material.substr(0, material.length - 1);
		$.post('/aptitude/ajax_receipt_add', {
			'linkman': linkman,
			'phone': phone,
			'content': content,
			'sj_time': sj_time,
			'sd_unit': sd_unit,
			'material': material
		}, function(data) {
			if (200 === data.status) {
				message_box.show(data.data);
				gDialog.fClose();
				if (typeof(pageObj) != "undefined") {
					if (data.page < pageObj.get_page_count()) {
						pageObj.dec_page_count(); //-1
						if (pageObj.get_page_index() > pageObj.get_page_count()) {
							pageObj.go_page(pageObj.get_page_count());
						} else {
							pageObj.cur_page();
						}
					} else {
						pageObj.cur_page();
					}
				}
			} else {
				message_box.show(data.data);
			}
		}, 'json');
		//console.log(form_data)
	})
})</script>
